import {
    orderList,
    orderPage,
    orderAdd,
    orderUpdate,
    orderDelete
} from '@/api/charge.order'
export default {
    namespaced: true,
    //数据保存在State中
    state: {
        menu: []
    },
    //对于后台的请求放在actions中
    actions: {
        getOrderList() {
            return new Promise((resolve, reject) => {
                orderList().then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        //context 对象是vuex框架自己放入到第一个参数,界面上调用时传入的参数,需要放入第二个参数
        getOrderPage(context, data) {
            return new Promise((resolve, reject) => {
                orderPage(data).then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        addorder(context, data) {
            return new Promise((resolve, reject) => {
                console.log('addorder')
                console.log(data)
                orderAdd(data).then(
                    resolve()
                )
            })
        },

        updateorder(context, data) {
            return new Promise((resolve, reject) => {
                console.log('updateorder')
                console.log(data)
                orderUpdate(data).then(
                    resolve()
                )
            })
        },

        deleteorder(context, id) {
            return new Promise((resolve, reject) => {
                orderDelete(id).then(
                    resolve()
                )
            })
        }
    }
}